#ifndef WXSPROJECT_H
#define WXSPROJECT_H

#include <M_Code_project.h>
#include <tinyxml.h>
#include "wxsresourcetree.h"

class wxSmith;
class wxsResource;
class wxsGUI;

class wxsProject {
  public:
    wxsProject( M_Code_Project* Project );
    ~wxsProject();
    inline M_Code_Project* GetM_Code_Project() { return m_Project; }
    void ReadConfiguration( TiXmlElement* element );
    void WriteConfiguration( TiXmlElement* element );
    wxsResource* FindResource( const wxString& Name );
    void Configure();
    cbConfigurationPanel* GetProjectConfigurationPanel( wxWindow* parent );
    wxString GetProjectPath();
    bool AddResource( wxsResource* Resource );
    inline int GetResourcesCount() { return ( int )m_Resources.Count(); }
    inline wxsResource* GetResource( int Index ) { return ( ( Index >= 0 ) & ( Index < GetResourcesCount() ) ) ? m_Resources[Index] : 0; }
    bool DelResource( wxsResource* Resource );
    bool CanOpenEditor( const wxString& FileName );
    bool TryOpenEditor( const wxString& FileName );
    inline wxsGUI* GetGUI() { return m_GUI; }
    void SetGUI( wxsGUI* NewGUI );
    void NotifyChange();
    inline bool GetWasModifiedDuringLoad() { return m_WasModifiedDuringLoad; }
    void UpdateName();
    bool RecoverWxsFile( const wxString& ResourceDescription );
  private:
    WX_DEFINE_ARRAY( wxsResource*, ResourcesT );
    WX_DECLARE_STRING_HASH_MAP( wxsResourceItemId, ResBrowserIdsT );
    typedef ResBrowserIdsT::iterator ResBrowserIdsI;
    wxString m_ProjectPath;
    M_Code_Project* m_Project;
    wxsResourceItemId m_TreeItem;
    ResourcesT m_Resources;
    ResBrowserIdsT m_ResBrowserIds;
    wxsGUI* m_GUI;
    TiXmlElement m_UnknownConfig;
    TiXmlElement m_UnknownResources;
    bool m_WasModifiedDuringLoad;
    wxsResourceItemId GetResourceTypeTreeId( const wxString& Name );
    friend class wxsResource;
};

#endif
